#line 1 "D:/Archivio/mikroC/tric-ricotta/util.c"
#line 1 "d:/archivio/mikroc/tric-ricotta/config.h"
#line 1 "d:/archivio/mikroc/tric-ricotta/util.h"



void Soft_UART_Write_Text(char* testo);
unsigned short UTIL_checkBattery();
void UTIL_initCheckBattery();
#line 11 "D:/Archivio/mikroC/tric-ricotta/util.c"
void Soft_UART_Write_Text(char* testo) {
 char cnt;
 for (cnt=0; cnt<strlen(testo); cnt++) {
 Soft_UART_Write(testo[cnt]);
 }
}

unsigned short UTIL_checkBattery() {
 unsigned short error;
 unsigned int vbatt;
 float normalizedVoltage;


 ADCON0 = ADCON0|0x02;
 while (ADCON0&0x02) {}

 vbatt = ADRESL;
 vbatt |= (ADRESH << 8);

 normalizedVoltage = vbatt *  55 ;
 if (normalizedVoltage <=  9.4 ) error = 1;
 else error = 0;
 return error;
}

void UTIL_initCheckBattery() {

 ADCON2 = 0xBE;

 ADCON0 = ADCON0|0x01;

}
